package engineer.clientapp.servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.namespace.QName;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

/**
 * Servlet implementation class SendToGenerateForSelectedAutomatServlet
 */
@WebServlet("/SendToGenerateForSelectedAutomatServlet")
public class SendToGenerateForSelectedAutomatServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setCharacterEncoding("UTF-8");
		String ret=null;
		PrintWriter out=response.getWriter();
		String userID = request.getParameter("userID");
		String machineID = request.getParameter("machineID");
		String type = request.getParameter("type");
		
		try{
		    String endpoint = "http://localhost:8080/Server/services/CreatePDF";
		    Service service = new Service();
		    Call call = (Call) service.createCall();
		    call.setTargetEndpointAddress( new java.net.URL(endpoint) );
		    call.setOperationName( new QName("http://util.com.ps", "generateRaportForSelectedAutomats") );
		    int id=Integer.parseInt(userID);
		    int idMachine= Integer.parseInt(machineID);
		    ret = (String) call.invoke( new Object[] {id, idMachine, type} );
		    out.println(ret);
		 
		}catch(Exception e){
		       e.printStackTrace();
		    }
	
}
}
